package com.xiaoshuidi.cloud.framework.pay.core.client.impl.tongshangyun.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@AllArgsConstructor
@Getter
public enum OrderStatusEnum {
    UNPAID(1L, "1", "未支付"),
    TRANSACTION_FAILED(3L, "3", "交易失败"),
    TRANSACTION_SUCCESS(4L, "4", "交易成功"),
    TRANSACTION_SUCCESS_REFUND(5L, "5", "交易成功-发生退款"),
    CLOSED(6L, "6", "关闭"),
    IN_PROGRESS(99L, "99", "进行中"),
    TRANSACTION_SUCCESS_RETRUN_TICKET(8L, "8", "交易成功-发生退票");

    private final Long code;
    private final String status;
    private final String name;

    public static OrderStatusEnum getEnumByStatus(String status) {
        OrderStatusEnum orderStatusEnum = Arrays.stream(OrderStatusEnum.values()).filter(p -> p.status.equals(status)).findFirst().orElse(null);
        Assert.isTrue(orderStatusEnum != null, "OrderStatusEnum:{}不存在", status);
        return orderStatusEnum;
    }
}
